package com.wang.jmonkey.common.model.pojo;

import com.wang.jmonkey.common.model.enums.BooleanEnum;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @Description 登陆用户的UserDetails
 * @Author HeJiawang
 * @Date 2021/5/11 10:02
 */
public class LoginUser implements UserDetails {

    private String username;

    private String password;

    private BooleanEnum isLock;

    private BooleanEnum isAdmin;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return isLock == BooleanEnum.NO;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public BooleanEnum getIsLock() {
        return isLock;
    }

    public void setIsLock(BooleanEnum isLock) {
        this.isLock = isLock;
    }

    public BooleanEnum getIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(BooleanEnum isAdmin) {
        this.isAdmin = isAdmin;
    }
}
